<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jQuery-3.7.1.js"></script>
    <script>
        async function show() {
            try{
                // fetch 返回一个promise对象
                let res = await fetch('http://localhost:8080/emp/hxx1.do');
                // res.json() 返回一个json对象
                let json = await res.json();
                json.forEach(item=>{
                    $("#tid").append(
                        `<tr>
                            <td>${item.id}</td>
                            <td>${item.name}</td>
                            <td>${item.age}</td>
                            <td>${item.time}</td>
                        </tr>`
                    )
                })
            }catch(err){
                console.log(err)
            }
        }
    </script>
</head>
<body onload="show()">
<button id="btn" onclick="show()">按钮</button><br>
<table border="1" id="tid">
    <tr>
        <th>主键</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年龄</th>
    </tr>
</table>
</body>
</html>